package com.onemileshop.controls;

import java.util.ArrayList;

import com.onemileshop.app.R;
import com.onemileshop.entiy.model.EOrder;
import com.onemileshop.utils.UtiDateTime;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdpLV_HomeOrderList extends BaseAdapter
{
   private ArrayList<EOrder> mList;
   private Context mContext;
   private LayoutInflater mInflater;
   
   public AdpLV_HomeOrderList(ArrayList<EOrder> list,Context _context)
   {
	  mList=list;
	  mContext = _context;
	  mInflater = LayoutInflater.from(_context);
   }

   @Override
   public int getCount()
   {
	  return mList.size();
   }

   @Override
   public Object getItem(int position)
   {
	  return mList.get(position);
   }

   @Override
   public long getItemId(int arg0)
   {
	  return 0;
   }

   @Override
   public View getView(int position, View convertView, ViewGroup arg2)
   {
	  try
	  {
		 convertView = mInflater.inflate(R.layout.home_orderlist_item, null);		
		 TextView txtConsignee = (TextView) convertView.findViewById(R.id.txtConsignee_home_orderlist);
		 TextView txtPhone=(TextView)convertView.findViewById(R.id.txtPhone_home_orderlist);	
		 TextView txtDate = (TextView) convertView.findViewById(R.id.txtDeliveryDate_home_orderlist);
		 TextView txtPrice = (TextView) convertView.findViewById(R.id.txtPrice_home_orderlist);
		 TextView txtAddress = (TextView) convertView.findViewById(R.id.txtAddress_home_orderlist);

		 int isFinish=Integer.valueOf(mList.get(position).getOrderType());
//		 if(isFinish==1)
//		 {
//			convertView.setBackgroundResource(R.color.LightGolden);
//		 }

		 txtConsignee.setText(mList.get(position).getOrderName());
		 txtDate.setText(mList.get(position).getEarliestTime().split(" ")[1]+"~"+mList.get(position).getLatestTime().split(" ")[1]);
		 txtAddress.setText(mList.get(position).getOrderAddress());
		 txtPrice.setText(mList.get(position).getTotalPrice());
		 txtPhone.setText(mList.get(position).getOrderMobile());

		 return convertView;
	  }
	  catch (Exception e)
	  {
		 
	  }
	  return new View(mContext);
   }

}
